const express = require('express')
const { md5 } = require('utility')
const db = require('./utils/db')

const app = express()

app.listen(3006, () => console.log('服务器启动成功'))

app.use(express.urlencoded({ extended: true }))

app.post('/api/login', (req, res) => {
  const { username, password } = req.body
  // console.log(username, password);
  const newPassword = md5(password)
  // console.log(newPassword);
  db(
    `SELECT * FROM users WHERE username='${username}' AND password='${newPassword}';`,
    (err, array) => {
      console.log(err)
      console.log(array)
    },
  )
})
